import Vue from 'vue'
import Router from 'vue-router'
import store from 'store'
import RouterUtil from 'utils/routerUtil';
import SystemUtil from 'utils/systemUtil';

const menus = store.state.menu.menus;
let addMenus = [];
if (menus !== null) {
  RouterUtil.getRouteData(addMenus, menus);
}

Vue.use(Router);

let routes = [{
  path: '/',
  name: '网站主页',
  component: resolve => require(["components/login"], resolve)
}, {
  path: '/login',
  name: 'login',
  component: resolve => require(["components/login"], resolve)
}, {
  path: '/bindAccount',
  name: 'bindAccount',
  component: resolve => require(["components/bindAccount"], resolve)
}, {
  path: '/weChatLogin',
  name: 'weChatLogin',
  component: resolve => require(["components/bindAccount/weChatLogin"], resolve)
}, {
  path: '/home',
  name: '系统设置',
  component: resolve => require(["components/home"], resolve),
  children: [{
    path: '/homeMain',
    name: '首页',
    component: resolve => require(["components/common/homeMain"], resolve),
    meta: {
      requireAuth: true
    }
  }, ...addMenus]
}, {
  path: '*',
  component: resolve => require(["components/404"], resolve)
}];

export default new Router({
  mode: 'history',
  base: SystemUtil.getProjectName(),
  routes
})
